#include <iostream>
#include <functional>
using namespace std;


int f(int a, int b)
{
	return a + b;
}
struct Functor
{
public:
	int operator() (int a, int b)
	{
		return a + b;
	}
};
class Plus
{
public:
	static int plusi(int a, int b)
	{
		return a + b;
	}
	double plusd(double a, double b)
	{
		return a + b;
	}
};
int main()
{
	//可以认为包装器的底层是仿函数，因为包装器也是一个类，实际调用也是用仿函数对象(重载operator())去调用。
	function<int(int, int)> f1;
	f1 = f;
	function<int(int, int)> f2(f);

	cout << f1(10, 20) << endl;
	cout << f2(10, 20) << endl;

	f1 = Functor();//仿函数匿名对象
	function<int(int, int)> f3(Functor());// vs识别报错
//	function<int(int, int)> f3 = Functor();
	cout << f1(100, 200) << endl;
	cout << f3(100, 200) << endl;



	return 0;
}

